﻿<Window x:Name="window" x:Class="Minesweeper.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:l="clr-namespace:Minesweeper"
        xmlns:c="clr-namespace:Minesweeper.Converter"
        xmlns:controls="clr-namespace:Minesweeper.Windows.Controls"
        Title="MainWindow" Height="750" Width="1225">
    <Window.Resources>
        <c:MultiMarginConverter x:Key="multiMarginConverter"></c:MultiMarginConverter>
        <c:FontSizeConverter x:Key="fontSizeConverter"></c:FontSizeConverter>
        <c:ButtonForegroundConverter x:Key="btnForegroundConverter"></c:ButtonForegroundConverter>
        <controls:FieldButton x:Key="FieldButton"></controls:FieldButton>
    </Window.Resources>
    <Grid Name="OuterGrid">
        <Grid.Resources>
            <Style x:Key="MyFocusVisual">
                <Setter Property="Control.Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Control}">
                            <Grid Margin="3 2">
                                <Rectangle Name="r1" StrokeThickness="1" Stroke="Black" StrokeDashArray="2 2"/>
                                <Border Name="border" Width="{TemplateBinding ActualWidth}" Height="{TemplateBinding ActualHeight}"  CornerRadius="2" BorderThickness="1" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>


            <Style x:Key="ShadowStyle">
                <Setter Property="Control.Foreground" Value="DarkGray" />
            </Style>

            <Style x:Key="FieldButton" TargetType="{x:Type controls:FieldButton}">
                <Setter Property="OverridesDefaultStyle" Value="True"/>
                <Setter Property="HorizontalAlignment" Value="Left" />
                <Setter Property="VerticalAlignment" Value="Top" />
                <Setter Property="Margin" Value="2"/>
                <Setter Property="FontFamily" Value="Verdana"/>
                <Setter Property="Width" Value="{Binding ButtonWidth, Mode=OneWay}" />
                <Setter Property="Height" Value="{Binding ButtonHeight, Mode=OneWay}" />
                <Setter Property="FontSize">
                    <Setter.Value>
                        <MultiBinding Converter="{StaticResource fontSizeConverter}">
                            <Binding Path="ButtonWidth" Mode="OneWay" />
                            <Binding Path="ButtonHeight" Mode="OneWay" />
                        </MultiBinding>
                    </Setter.Value>
                </Setter>
                <Setter Property="FontWeight" Value="Bold"/>
                <Setter Property="FocusVisualStyle" Value="{StaticResource MyFocusVisual}" />
                <Setter Property="Background" >
                    <Setter.Value>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" >
                            <GradientStop Color="#7f9ef6" Offset="0.2"/>
                            <GradientStop Color="#6e8adb" Offset="0.6"/>
                            <GradientStop Color="#7f9ef6" Offset="0.85"/>
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type controls:FieldButton}">
                            <Border Name="border" 
				                    BorderThickness="0.75"
				                    Padding="1,1" 
				                    BorderBrush="#3f4e78" 
				                    CornerRadius="1" 
				                    Background="{TemplateBinding Background}">
                                <Grid >
                                    <ContentPresenter HorizontalAlignment="Center" 
	                                                  VerticalAlignment="Center" Name="contentShadow" 
					                                  Style="{StaticResource ShadowStyle}">
                                        <ContentPresenter.RenderTransform>
                                            <TranslateTransform X="1.0" Y="1.0" />
                                        </ContentPresenter.RenderTransform>
                                    </ContentPresenter>
                                    <ContentPresenter HorizontalAlignment="Center" 
                                                      VerticalAlignment="Center" Name="content"/>
                                </Grid>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter Property="Background" >
                                        <Setter.Value>
                                            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" >
                                                <GradientStop Color="#7f9ef6" Offset="1"/>
                                            </LinearGradientBrush>
                                        </Setter.Value>
                                    </Setter>
                                </Trigger>
                                <Trigger Property="IsPressed" Value="True">
                                    <Setter Property="Background" >
                                        <Setter.Value>
                                            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" >
                                                <GradientStop Color="#FFFFD190" Offset="0.35"/>
                                                <GradientStop Color="Orange" Offset="0.95"/>
                                                <GradientStop Color="#FFFFD190" Offset="1"/>
                                            </LinearGradientBrush>
                                        </Setter.Value>
                                    </Setter>
                                    <Setter TargetName="content" Property="RenderTransform" >
                                        <Setter.Value>
                                            <TranslateTransform Y="1.0" />
                                        </Setter.Value>
                                    </Setter>
                                </Trigger>
                                <Trigger Property="IsDefaulted" Value="True">
                                    <Setter TargetName="border" Property="BorderBrush" Value="#FF282828" />
                                </Trigger>
                                <Trigger Property="IsFocused" Value="True">
                                    <Setter TargetName="border" Property="BorderBrush" Value="#FF282828" />
                                </Trigger>
                                <Trigger Property="IsEnabled" Value="False">
                                    <Setter TargetName="border" Property="Opacity" Value="0.7" />
                                    <Setter Property="Background" Value="White"></Setter>
                                    <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource Self}, Path=Value, Converter={StaticResource btnForegroundConverter}}" />
                                </Trigger>

                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Grid.Resources>
        <Grid Margin="10,10,10,100" Name="MainGrid" Background="#6e8adb" />
    </Grid>

</Window>
